home *** CD-ROM | disk | FTP | other *** search
/ Your Choice 3 / Your Choice Software Collection 3.iso / prgmming / swag05 / hardware.swg < prev    next >
Encoding:
Text File  |  1994-09-22  |  6.5 KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00003                                                                           1      05-25-9408:02ALL                      COLEK UMNICKI            Get CPU Type             SWAG9405            9      └╫   π{$D-} {$L-}πProgram Cpuu;ππConstπ    Cpu      : Array[1..4] of String[5] = ('8086','80286','80386','80486');π    Cpu8086  = 1;π    Cpu80286 = 2;π    Cpu80386 = 3;π    Cpu80486 = 4;ππFunction GetCPU_Type: Byte; Assembler;πASMπ MOV    DX, CPU8086π PUSH   SPπ POP    AXπ CMP    SP,AXπ JNE    @OUTπ MOV    DX, CPU80286π PUSHFππ POP    AXπ OR     AX,4000hπ PUSH   AXπ POPFπ PUSHFπ POP    AXπ TEST   AX,4000Hπ JE     @OUTπ MOV    DX,CPU80386π {"DB 66h" INDICATES '386 EXTENDED INSTRUCTION}π DB 66hπ MOV    BX,SPπ DB 66h, 83h, 0E4h, 0FChπ DB 66hπ PUSHFπ DB 66hπ POP AXπ DB 66hπ MOV    CX,AXπ DB 66h, 35h, 00hπ DB 00h, 04h, 00π DB 66hπ PUSH   AXπ DB 66hπ POPFπ DB 66hπ PUSHFπ DB 66hπ POP    AXπ DB 66h,25h, 00hπ DB 00h, 04h, 00hπ DB 66h, 81h, 0E1h, 00hπ DB 00h, 04h, 00hπ DB 66hπ CMP    AX,CXπ JE @NOT486π MOV DX, CPU80486π@NOT486:π DB 66hπ PUSH   CXπ DB 66hπ POPFπ DB 66hπ MOV    SP,BXπ@OUT:π MOV    AX,DXπEnd;ππBeginπ    Writeln; Writeln('I detected an ',Cpu[GetCpu_Type],' chip.');πEnd.π                                         2      05-25-9408:03ALL                      GREG ESTABROOKS          286/8088 code            SWAG9405            16     └╫   {πSE>I have Borland Pascal 7.0 and I ran acrost the idea of 286 and 8088 codeπSE>specs in a program.  How can you detect for a 286 CPU and if present,πSE>switch $G to $G+ ?ππ There should be a program somewhere in your TP disks that has a routineπ that detects whether or not a 286+ CPU is pressent. Unfortunately youπ can't have it change the status of $G. It's either on or off. You canπ either leave it on , detect CPU type, if its the wrong type leave aπ mesage and abort the program or not use the $G directive at all.ππ Here is a simple CPU detection routine in case you can't find the one Iπ mentioned:π}ππCONSTπ      CPU     :ARRAY[0..3] Of STRING[13] =('8088/V20','80286',π                                          '80386/80486','80486');πFUNCTION CpuType :WORD; ASSEMBLER;π                 {  Returns a value depending on the type of CPU        }π                 {          0 = 8088/V20 or compatible                  }π                 {          1 = 80286    2 = 80386/80486+               }πASMπ  Xor DX,DX                             {  Clear DX                     }π  Push DXπ  PopF                                  {  Clear Flags                  }π  PushFπ  Pop AX                                {  Load Cleared Flags           }π  And AX,$0F000                         {  Check hi bits for F0h        }π  Cmp AX,$0F000π  Je @Quit                              {  Quit if 8088                 }π  Inc DXπ  Mov AX,$0F000                         {  Now Check For 80286          }π  Push AXπ  PopFπ  PushFπ  Pop AXπ  And AX,$0F000                         {  If The top 4 bits aren't set }π  Jz @Quit                              {  Its a 80286+                 }π  Inc DX                                {  Else its a 80386 or better   }π@Quit:π  Mov AX,DX                             {  Return Result in AX          }πEND;{CpuType}ππBEGINπ  Writeln('Your CPU is a ',CPU[CpuType]);πEND.π                   3      05-26-9406:14ALL                      ANDRES CVITKOVICH        Another Which CPU        SWAG9405            26     └╫   >     Hi!  I was wondering.. does anyone have any TP codes to findπ > out what typeπ > of machine (ie. XT, 286, 386, 486, Pentium, etc) that the userπ > is running?π > The type of coding (Inline Assembly or BASM).. I don't care..π > just make sureπ > that it is usable by Turbo Pascal 6.0 =8)  Thanks!ππ{π  GetCPU                             Byteπ  ───────────────────────────────────────π  Ermittelt den arbeitenden CPU-Typ.  Derπ  zurückgelieferte Code entspricht:ππ     0 - Intel 8088π     1 - Intel 8086π     2 - NEC V20π     3 - NEC V30π     4 - Intel 80188π     5 - Intel 80186π     6 - Intel 80286 (or Harris or... whatever)π     7 - Intel 80386 (or AMD or Cyrix (?) or... whatever)π     8 - Intel 80486 (or AMD or Cyrix (?) or... ;))π     9 - Intel Pentium (still looking forward for clones... ;))π}πFunction GetCPU: Byte; Assembler;πConst processor: Byte= $FF;πAsmπ    mov  al, processorπ    cmp  al, 0FFhπ    jne  @get_outπ    pushfπ    xor  bx,bxπ    push bxπ    popfπ    pushfπ    pop  bxπ    and  bx,0F000hπ    cmp  bx,0F000hπ    je   @no286π    mov  bx,07000hπ    push bxπ    popfπ    pushfπ    pop  bxπ    and  bx,07000hπ    jne  @test486π    mov  dl,6π    jmp  @endπ@test486:π    mov  dl,7π    xor  si,siπ    mov  ax,csπ{$IFDEF DPMI}π    add  ax,SelectorIncπ{$ENDIF}π    mov  es,axπ    mov  byte ptr es:[@queue486+11], 46h     { 46h == "INC SI" }π@queue486:π    nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nop; nopπ    or   si,siπ    jnz  @endπ    inc  dlπ    db   66h ; pushf      { pushfd }π    db   66h ; pushf      { pushfd }π    db   66h ; pop  ax    { pop eax }π    db   66h ; mov  cx,ax { mov ecx,eax }π    db   66h,35hπ    db   00h,00h,20h,00h  { xor eax,(1 shl 21) (Pentium ID flag) }π    db   66h ; push ax    { push eax }π    db   66h ; popf       { popfd }π    db   66h ; pushf      { pushfd }π    db   66h ; pop  ax    { pop eax }π    db   66h,25hπ    db   00h,00h,20h,00h  { and eax,(1 shl 21) }π    db   66h,81h,0E1hπ    db   00h,00h,20h,00h  { and ecx,(1 shl 21) }π    db   66h ; cmp ax,cx  { cmp eax,ecx }π    je   @is486π    inc  dlπ@is486:π    db   66h ; popf       { popfd }π    jmp  @endπ@no286:π    mov  dl,5π    mov  al,0FFhπ    mov  cl,21hπ    shr  al,clπ    jnz  @testdatabusπ    mov  dl,2π    stiπ    xor  si,siπ    mov  cx,0FFFFhπ{$IFDEF DPMI}π    push esπ    push dsπ    pop  esπ{$ENDIF}π    rep  seges lodsb      { == rep lods byte ptr es:[si] }π{$IFDEF DPMI}π    pop  esπ{$ENDIF}π    or   cx,cxπ    jz   @testdatabusπ    mov  dl,1π@testdatabus:π    push csπ{$IFDEF DPMI}π    pop  axπ    add  ax,SelectorIncπ    mov  es,axπ{$ELSE}π    pop  esπ{$ENDIF}π    xor  bx,bxπ    stdπ    mov  al,90hπ    mov  cx,3π    call @ip2diπ    cliπ    rep  stosbπ    cldπ    nop; nop; nopπ    inc  bxπ    nopπ    stiπ    or   bx,bxπ    jz   @end      { v20 or 8086 or 80186 }π    cmp  dl,1π    je   @its8088π    cmp  dl,2π    je   @itsV30π    cmp  dl,5π    jne  @endπ    mov  dl,4π    jmp  @endπ@its8088:π    xor  dl,dlπ    jmp  @endπ@itsV30:π    mov  dl,3π    jmp  @endπ@ip2di:π    pop  diπ    push diπ    add  di,9π    retnπ@end:π    popfπ    mov  al,dlπ    mov  processor,alπ@get_out:πEnd;π